package com.multiplayer.service.impl;

import java.util.List;

import com.multiplayer.dao.IReservationDao;
import com.multiplayer.dao.impl.ReservationDaoImpl;
import com.multiplayer.entity.Reservation;
import com.multiplayer.entity.StudyRoom;
import com.multiplayer.service.IReservationService;
import com.multiplayer.tools.DBTools;
import com.multiplayer.tools.PageData;

public class ReservationServiceImpl implements IReservationService {
	
	IReservationDao rd=new ReservationDaoImpl();
	@Override
	public List<Reservation> getAllReservation(String userid) {
		// 调用Dao的方法实现查看预约信息
		if (userid!=null) {
			return rd.getAllReservation(userid);
		}
		return null;
		
	}

	@Override
	public boolean delReservation(String userid) {
		// 调用dao的方法实现取消预约信息
		if (userid==null) {
			return false;
		}
		return rd.delReservation(userid);
	}

	@Override
	public PageData<Reservation> getReservationByPage(int page, int pageSize, String keywords) {
		// TODO Auto-generated method stub
		//当前页码不能小于1
		if(page<1)
		{page=1;}
		PageData<Reservation> pd = rd.getReservationByPage(page, pageSize, keywords);
		return pd;
	}

	@Override
	public boolean rejectReservation(int resid) {
		// TODO Auto-generated method stub
		IReservationDao reservationDao=new ReservationDaoImpl();
		if(reservationDao.rejectReservation(resid))
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	@Override
	public boolean acceptReservation(int resid) {
		// TODO Auto-generated method stub
		IReservationDao reservationDao=new ReservationDaoImpl();
		if(reservationDao.acceptReservation(resid))
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}
